/*     */ package com.qmsk.business.store.goodsprice.controller;
/*     */ 
/*     */ import com.qmsk.business.store.goodsprice.dao.GoodsPriceDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.gson.out.GsonEbRstData;
/*     */ import com.utils.gson.out.GsonEbUtils;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"goodsPrice"})
/*     */ public class GoodsPriceController
/*     */ {
/*  46 */   private static final Logger logger = Logger.getLogger(GoodsPriceController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GoodsPriceDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsId/{goodsId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getGsonOfGoodsId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("goodsId") Long goodsId)
/*     */   {
/*     */     try
/*     */     {
/*  56 */       Map params = new HashMap();
/*  57 */       MapUtils.addToMap(params, "goodsId", goodsId);
/*     */ 
/*  59 */       GsonEbRst gsonEbRst = this.dao.getGsonOfGoodsId(params);
/*  60 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  62 */       logger.error(e);
/*  63 */       ResponseUtils.setErrorMsgResponse(
/*  64 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsCode/{goodsCode}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getGsonOfGoodsCode(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("goodsCode") String goodsCode, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  74 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  76 */       Map params = new HashMap();
/*  77 */       MapUtils.addToMap(params, "goodsCode", goodsCode);
/*  78 */       MapUtils.addToMap(params, "shopId", shopId);
/*  79 */       GsonEbRst rst = this.dao.getGsonOfGoodsId(params, nPageIdx, nPageSize);
/*  80 */       ResponseUtils.setResponseResult(rst, response);
/*     */     } catch (Exception e) {
/*  82 */       logger.error(e);
/*  83 */       ResponseUtils.setErrorMsgResponse(
/*  84 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/barCode/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getGsonOfBarcode(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  93 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  95 */       String barCode = RequestUtils.getString(request, "barCode");
/*  96 */       Map params = new HashMap();
/*  97 */       MapUtils.addToMap(params, "barCode", barCode);
/*  98 */       MapUtils.addToMap(params, "shopId", shopId);
/*  99 */       GsonEbRst rst = this.dao.getGsonOfGoodsId(params, nPageIdx, nPageSize);
/* 100 */       if ((rst.isExistsData()) && 
/* 102 */         (ObjectComm.objectToInteger(rst.getResult().getValueOfIdx(0, 
/* 102 */         "nums")).intValue() < 
/* 102 */         1)) {
/* 103 */         ResponseUtils.setErrorMsgResponse("库存不足", response);
/* 104 */         return;
/*     */       }
/*     */ 
/* 107 */       ResponseUtils.setResponseResult(rst, response);
/*     */     } catch (Exception e) {
/* 109 */       logger.error(e);
/* 110 */       ResponseUtils.setErrorMsgResponse(
/* 111 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsNo"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getGsonOfGoodsCodeBom(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try {
/* 119 */       String goodsNo = RequestUtils.getString(request, "goodsNo");
/* 120 */       GsonEbRst rst = this.dao.getGsonOfGoodsNo(shopId, goodsNo);
/* 121 */       if (rst.isExistsData())
/*     */       {
/* 123 */         if (ObjectComm.objectToInteger(rst.getResult()
/* 123 */           .getValueOfIdx(0, "nums"), Integer.valueOf(0)).intValue() < 
/* 123 */           1) {
/* 124 */           ResponseUtils.setErrorMsgResponse("库存不足", response);
/* 125 */           return; }
/* 126 */         if (ObjectComm.objectToInteger(rst.getResult()
/* 127 */           .getValueOfIdx(0, "bom"), Integer.valueOf(0)).intValue() == 
/* 127 */           1) {
/* 128 */           Long goodsId = ObjectComm.objectToLong(rst.getResult()
/* 129 */             .getValueOfIdx(0, "id"));
/* 130 */           GsonEbRst rstBom = this.dao.getGsonOfGoodsBarcodeBom1(shopId, goodsId);
/* 131 */           if ((rstBom.isSuccess()) && (rstBom.isExistsData())) {
/* 132 */             for (int i = 0; i < rstBom.getResult().getDataLength(); ++i)
/*     */             {
/* 134 */               if (ObjectComm.objectToInteger(rstBom.getResult()
/* 134 */                 .getValueOfIdx(i, "nums"), Integer.valueOf(0)).intValue() < 
/* 134 */                 1) {
/* 135 */                 ResponseUtils.setErrorMsgResponse("库存不足", 
/* 136 */                   response);
/* 137 */                 return;
/*     */               }
/*     */             }
/*     */ 
/* 141 */             ResponseUtils.setResponseResult(GsonEbUtils.toGsonEbRst(rst, rstBom), response);
/* 142 */             return; }
/* 143 */           ResponseUtils.setResponseResult(rst, response);
/*     */ 
/* 145 */           return; }
/* 146 */         ResponseUtils.setResponseResult(rst, response);
/*     */ 
/* 148 */         return; }
/* 149 */       ResponseUtils.setResponseResult(rst, response);
/*     */     }
/*     */     catch (Exception e) {
/* 152 */       logger.error(e);
/* 153 */       ResponseUtils.setErrorMsgResponse(
/* 154 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/barCode"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getGsonOfBarcodeBom(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try {
/* 162 */       String barCode = RequestUtils.getString(request, "barCode");
/* 163 */       GsonEbRst rst = this.dao.getGsonOfGoodsBarcodeBom0(shopId, barCode);
/* 164 */       if (rst.isExistsData())
/*     */       {
/* 166 */         if (ObjectComm.objectToInteger(rst.getResult()
/* 166 */           .getValueOfIdx(0, "nums"), Integer.valueOf(0)).intValue() < 
/* 166 */           1) {
/* 167 */           ResponseUtils.setErrorMsgResponse("库存不足", response);
/* 168 */           return; }
/* 169 */         if (ObjectComm.objectToInteger(rst.getResult()
/* 170 */           .getValueOfIdx(0, "bom"), Integer.valueOf(0)).intValue() == 
/* 170 */           1) {
/* 171 */           Long goodsId = ObjectComm.objectToLong(rst.getResult()
/* 172 */             .getValueOfIdx(0, "id"));
/* 173 */           GsonEbRst rstBom = this.dao.getGsonOfGoodsBarcodeBom1(shopId, goodsId);
/* 174 */           if ((rstBom.isSuccess()) && (rstBom.isExistsData())) {
/* 175 */             for (int i = 0; i < rstBom.getResult().getDataLength(); ++i)
/*     */             {
/* 177 */               if (ObjectComm.objectToInteger(rstBom.getResult()
/* 177 */                 .getValueOfIdx(i, "nums"), Integer.valueOf(0)).intValue() < 
/* 177 */                 1) {
/* 178 */                 ResponseUtils.setErrorMsgResponse("库存不足", 
/* 179 */                   response);
/* 180 */                 return;
/*     */               }
/*     */             }
/*     */ 
/* 184 */             ResponseUtils.setResponseResult(GsonEbUtils.toGsonEbRst(rst, rstBom), response);
/* 185 */             return; }
/* 186 */           ResponseUtils.setResponseResult(rst, response);
/*     */ 
/* 188 */           return; }
/* 189 */         ResponseUtils.setResponseResult(rst, response);
/*     */ 
/* 191 */         return; }
/* 192 */       ResponseUtils.setResponseResult(rst, response);
/*     */     }
/*     */     catch (Exception e) {
/* 195 */       logger.error(e);
/* 196 */       ResponseUtils.setErrorMsgResponse(
/* 197 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 206 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 208 */       Map params = new HashMap();
/* 209 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/* 210 */       MapUtils.addPercentToMap(params, "name", 
/* 211 */         RequestUtils.getString(request, "name"));
/*     */ 
/* 229 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 230 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 232 */       logger.error(e);
/* 233 */       ResponseUtils.setErrorMsgResponse(
/* 234 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/* 242 */       Map params = new HashMap();
/* 243 */       MapUtils.addToMap(params, "id", id);
/* 244 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/* 245 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 247 */       logger.error(e);
/* 248 */       ResponseUtils.setErrorMsgResponse(
/* 249 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 267 */       int nResult = 0;
/*     */ 
/* 269 */       String sData = RequestUtils.getStringOfData(request);
/* 270 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 271 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 272 */         for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/* 273 */           GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/* 274 */           r.autoAddHeadData("productDate", new Date());
/* 275 */           r.autoAddHeadData("shopId", shopId);
/*     */         }
/* 277 */         nResult = this.dao.applyUpdates(p, "id");
/*     */       }
/*     */ 
/* 280 */       if (nResult > 0)
/* 281 */         DbConnection.commit();
/*     */       else {
/* 283 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 290 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 291 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 292 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 295 */       logger.error(e);
/* 296 */       DbConnection.rollback();
/* 297 */       ResponseUtils.setErrorMsgResponse(
/* 298 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 299 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 318 */       int nResult = 0;
/* 319 */       String sData = RequestUtils.getStringOfData(request);
/* 320 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 321 */       if (p != null) {
/* 322 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 324 */       if (nResult > 0)
/* 325 */         DbConnection.commit();
/*     */       else {
/* 327 */         DbConnection.rollback();
/*     */       }
/* 329 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 330 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 331 */         response);
/*     */     } catch (Exception e) {
/* 333 */       logger.error(e);
/* 334 */       DbConnection.rollback();
/* 335 */       ResponseUtils.setErrorMsgResponse(
/* 336 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 337 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 353 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 355 */       String[] strParams = id.split(",");
/* 356 */       int nResult = this.dao.deleteParams(strParams);
/* 357 */       if (nResult > 0)
/* 358 */         DbConnection.commit();
/*     */       else {
/* 360 */         DbConnection.rollback();
/*     */       }
/* 362 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 363 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 364 */         response);
/*     */     } catch (Exception e) {
/* 366 */       DbConnection.rollback();
/* 367 */       logger.error(e);
/* 368 */       ResponseUtils.setErrorMsgResponse(
/* 369 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 370 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"check/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void check(HttpServletRequest request, HttpServletResponse response)
/*     */     throws SQLException
/*     */   {
/* 391 */     int nResult = 0;
/*     */     try
/*     */     {
/* 405 */       if (nResult > 0)
/* 406 */         DbConnection.commit();
/*     */       else {
/* 408 */         DbConnection.rollback();
/*     */       }
/* 410 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 411 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 412 */         response);
/*     */     } catch (Exception e) {
/* 414 */       DbConnection.rollback();
/* 415 */       logger.error(e);
/* 416 */       ResponseUtils.setErrorMsgResponse(
/* 417 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 418 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.goodsprice.controller.GoodsPriceController
 * JD-Core Version:    0.5.3
 */